<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="box"></div>
    <script>
      const obj = {};
      Reflect.set(obj, "name", 100);
      console.log(obj, Reflect.get(obj, "name"));

      //   主要配合proxy使用
      let set = new Set();
      const setProxy = new Proxy(set, {
        get(target, prop, receiver) {
          let val = Reflect.get(target, prop);
          if (val instanceof Function) {
            return val.bind(target);
          }
          return val;
        },
        set(target, prop, value) {
          console.log([...arguments], "参数剩余");
          //   return Reflect.set(target, prop, value);
          return Reflect.set(...arguments);
        },
      });
      //   10.Proxy.html:55 Uncaught TypeError: Method Set.prototype.add called on incompatible receiver #<Set>
      setProxy.add("5");
      setProxy.b = 50;
    </script>
  </body>
</html>
